package com.demo.streamdemo1;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        List<Dish> menu = DishUtil.getDishes();
        List<String> lowCaloricDishesName =
                menu.parallelStream().filter(d -> d.getCalories() < 400)
                    .sorted(Comparator.comparing(Dish::getCalories))
                    .map(Dish::getName)
                    .collect(Collectors.toList());
        System.out.println(lowCaloricDishesName);

        List<String> threeHightCaloricDishNames =
                menu.stream()
                    .filter(d -> d.getCalories() > 300)
                    .map(Dish::getName)
                    .limit(3)
                    .collect(Collectors.toList());
        System.out.println("Hight caloric dishes: " + threeHightCaloricDishNames);

        long count = menu.stream()
                          .filter(d -> d.getCalories() > 300)
                          .distinct()
                          .limit(3)
                          .count();
        System.out.println(count);
    }
}
